def find_the_sum(coins_value_input, M, N):
    coins_value = []
    for i in coins_value_input:
        coins_value.append(i)
        coins_value.append(i)
    n_sum = 0
    n_sum_list = []
    answer = []
    answer_list = []
    if N < coins_value[0]:
        return 0
        #print(0)
    else:
        for i in range(2*M - 1, -1, -1):
            if coins_value[i] <= N:
                position = i
                break
        for j in range(position, -1, -1):    
            for i in range(j, -1, -1):
                n_sum += coins_value[i]
                n_sum_list.append(coins_value[i])
                ##print('j =', j)
                ##print('i =', i)
                ##print('n_sum =', n_sum)
                if n_sum > N:
                    n_sum -= coins_value[i]
                    ##print('n_sum =', n_sum)
                    n_sum_list.pop(-1)
                if n_sum == N:
                ##return n_sum, n_sum_list
                ##print(len(n_sum_list))
                ##print(' '.join([str(i)  for i in n_sum_list]))
                    answer_list.append(n_sum_list)
                    break
            n_sum = 0
            n_sum_list = []
            ##print('n_sum =', n_sum)
        for i in range(2*M):
            n_sum += coins_value[i]
        if answer_list != []:
            ##minimum = 2*M
            minimum_index = 0
            for i in range(len(answer_list)):
                if len(answer_list[i]) < len(answer_list[minimum_index]):
                    minimum_index = i
                    ##print('minimum_index =', minimum_index)
            return answer_list[minimum_index]
            #print(answer[minimum_index])
            #print(' '.join([str(i)  for i in answer_list[minimum_index]]))
        elif n_sum < N:
            return -1
            #print(-1)
        elif n_sum > N:
            return 0
            #print(0)
                                        
if __name__ == '__main__':
    N, M = map(int, input().split())
    coins_value_input = list(map(int, input().split()))
    answer = find_the_sum(coins_value_input, M, N)
    if answer == -1:
        print(answer)
    elif answer == 0:
        print(answer)
    else:
        print(len(answer))
        print(' '.join([str(i)  for i in answer]))
